package com.smh.a04MapDemo5;

import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

public class TreeMapDemo2 {
    public static void main(String[] args) {

        Student s1 = new Student("zhangsan",15);
        Student s2 = new Student("lisi",12);
        Student s3 = new Student("wangwu",12);
        Student s4 = new Student("maliu",34);

        Map<Student,String> tm = new TreeMap<>();

        tm.put(s1,"hebei");
        tm.put(s2,"tianjin");
        tm.put(s3,"jinan");
        tm.put(s4,"beijing");

        Set<Map.Entry<Student, String>> entries = tm.entrySet();
        for (Map.Entry<Student, String> entry : entries) {

            System.out.println(entry.getKey()+"="+entry.getValue());
        }

    }
}
